//
//  BVNavigationController.m
//  BuyVegetable
//
//  Created by yushanchang on 16/9/28.
//  Copyright © 2016年 com.yinding. All rights reserved.
//

#import "BVNavigationController.h"
#import "UIBarButtonItem+BVItem.h"

@interface BVNavigationController ()<UIGestureRecognizerDelegate>

@end

@implementation BVNavigationController
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}

- (void)viewDidLoad{
    [super viewDidLoad];
    self.navigationBar.translucent = NO;
    self.interactivePopGestureRecognizer.delegate = self;
}

/**
 *  设置导航条属性
 */
+ (void)initialize{

    UINavigationBar *navigationBar = [UINavigationBar appearance];
    navigationBar.barTintColor = [UIColor BVBaseOrangeColor];
    NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
    attrs[NSForegroundColorAttributeName] = [UIColor whiteColor];
//    attrs[NSFontAttributeName] = [UIFont systemFontOfSize:30];
    [navigationBar setTitleTextAttributes:attrs];
    [navigationBar setTintColor:[UIColor whiteColor]];
    
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    if(self.childViewControllers.count > 0) {
        
        viewController.hidesBottomBarWhenPushed = YES;
        viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem barButtonItemWithImage:[UIImage imageNamed:@"back_3"] target:self action:@selector(navigationBackClick) forControlEvents:UIControlEventTouchUpInside];
    }
    [super pushViewController:viewController animated:animated];
}

#pragma mark - 返回按钮
- (void)navigationBackClick{
    [self popViewControllerAnimated:YES];
}

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
    return YES;
}

//- (UIStatusBarStyle)preferredStatusBarStyle {
//    return UIStatusBarStyleLightContent;
//}

@end
